﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class NewsDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            judje();
        }

    }

    /// <summary>
    /// 判断
    /// </summary>
    private void judje()
    {
        if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != "")
        {
            BindWithId(Request.QueryString["ID"]);
        }
    }
    /// <summary>
    /// 增加点击数
    /// </summary>
    /// <param name="id">文章ID</param>
    private void addPageHit(string id)
    {
        string sql = "update News_Info set newsHits=newsHits+1 where newsID=" + id;
        DataAccess.ExecuteSQL(sql, null);
    }
    /// <summary>
    /// 显示文章
    /// 2010 11 18
    /// 水亚亚
    /// </summary>
    /// 2011.4.8修改显示-朱胜贤
    /// <param name="id"></param>
    private void BindWithId(string id)
    {
        try
        {
            // 添加点击数
            addPageHit(id);
            // 查找
            string sql = "select newsID,newsTitle,newsContent,newsType,newsTime,newsFrom,newsHits,newsKeywords from News_Info where newsID=" + id + " and newsIsShow=1";
            DataTable dt = DataAccess.GetDataTable(sql, null);
            lblTitle.Text = dt.Rows[0]["newsTitle"].ToString();
            lblInfo.Text = "来源：<span class=\"info_t\">" + dt.Rows[0]["newsFrom"].ToString() + "</span>　发布时间：<span class=\"info_t\">" + dt.Rows[0]["newsTime"].ToString() + "</span>　点击数：<span class=\"info_t\">" + dt.Rows[0]["newsHits"].ToString() + "</span>";
            lblContent.Text = dt.Rows[0]["newsContent"].ToString();
            lblTitleTop.Text = "<a href='News.aspx?Cat=" + dt.Rows[0]["newsType"].ToString() + "'>" + dt.Rows[0]["newsType"].ToString() + "</a> > " + (dt.Rows[0]["newsTitle"].ToString().Length > 15 ? dt.Rows[0]["newsTitle"].ToString().Substring(0, 14) + "..." : dt.Rows[0]["newsTitle"].ToString());
        }
        catch { }

    }
}